問題描述
pg_dump 數據庫轉儲是“當時”轉儲嗎? (Is a pg_dump DB dump 'at-that-time' dump?)
I know PostgresQL pg_dump
guarantees consistency even if DB is modified while dump is going on, but I want to know if the final dump contains any data modified/inserted after the dump started.
To elaborate:
- Time t: I start pg_dump
- Time t+1: There are updates/inserts to the database
- Time t+x: pg_dump completes.
I don't want any of the modifications done in the 'x' period to be present in the dump file.
Is this possible?
參考解法
方法 1:
This was answered in another SO question: Doing pg_dump while still many active transaction.
The short answer is yes: pg_dump opens a transaction and no changes made to the database will be visible to it during the dump, so pg_dump snapshots are atomic and are a consistent snapshot (iow, no foreign key or other constraints will be violated in the snapshot).
HTH
(by Finslicer、Kyle Burton)